#!/bin/bash
################################################################################
# Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The OpenAirInterface Software Alliance licenses this file to You under 
# the Apache License, Version 2.0  (the "License"); you may not use this file
# except in compliance with the License.  
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#-------------------------------------------------------------------------------
# For more information about the OpenAirInterface (OAI) Software Alliance:
#      contact@openairinterface.org
################################################################################
# file run_test_scenario
# brief
# author Lionel Gauthier
# company Eurecom
# email: lionel.gauthier@eurecom.fr
# 
# This scrip run the network scenario contained in the specified folder given in argument
################################
# include helper functions
################################
THIS_SCRIPT_PATH=$(dirname $(readlink -f $0))
source $THIS_SCRIPT_PATH/../BUILD/TOOLS/build_helper


function main()
{
  if [ ! -z "$1" ]; then
    if [ ! -d $1 ]; then
      echo_fatal "Error: Please provide a valid path to the desired test scenario dir" 
    fi
    cd $1
  fi
  if [ -f "./enb.replay.conf" ] && [ -f "./s1.xml" ] ; then
    # may be you want to speed up the run of the scenario if not optimized (capture with real UE)
    run_option=""
    if [ -f "./enb.replay.run_options.txt" ]; then
      run_options=$(< ./enb.replay.run_options.txt)
    fi
    # run XML scenario file
    echo_success "Running test `pwd`"
    test_epc --run --set-nw-interfaces --test-dir . --enb-config-file enb.replay.conf --scenario-file s1.xml $run_options
  else
      echo_fatal "Error: Did not found the required files (enb.replay.conf, s1.xml) for running the scenario in `pwd`" 
  fi
}

main "$@"
